package com.accounting.services.client;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.ws.client.core.WebServiceTemplate;

import com.accounting.services.AccountService;
import com.accounting.ws.Account;
import com.accounting.ws.accountservice.AccountDetailsRequest;
import com.accounting.ws.accountservice.AccountDetailsResponse;
import com.accounting.ws.accountservice.ObjectFactory;

public class AccountDetailsServiceClient implements AccountService {

	
	private static final ObjectFactory WS_CLIENT_FACTORY = new  ObjectFactory();
	
	@Autowired
	private  WebServiceTemplate webServiceTemplate;
	
	
	public Account getAccountDetails(String accountNumber) {
		// TODO Auto-generated method stub
		
		AccountDetailsRequest request = WS_CLIENT_FACTORY.createAccountDetailsRequest();
		request.setAccountNumber(accountNumber);
		
		AccountDetailsResponse response =(AccountDetailsResponse)webServiceTemplate.marshalSendAndReceive(request);		
		return response.getAccountDetails();
	}

}
